package com.market.manager.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.market.dao.WeeklyDao;
import com.market.domain.Product;
import com.market.domain.ProductPrice;
import com.market.domain.Weekly;
import com.market.manager.WeeklyManager;
@Service("weeklyManager")
public class WeeklyManagerImpl extends
		GenericManagerImpl<WeeklyDao, Weekly, Long> implements WeeklyManager {
	
	@Autowired
	@Override
	public void setDao(WeeklyDao dao) {
		this.dao = dao;		
	}

	public Weekly fetchOne(Weekly weekly) {
		return this.fetchOne(weekly.getId());
	}

	public List<ProductPrice> fetchProductPrices(Weekly weekly) {
		return this.dao.findProductPrices(weekly);
	}

	@Override
	public Weekly fetchOne(Long id) {
		Weekly weekly = super.fetchOne(id);
		weekly.setProductPrices(this.fetchProductPrices(weekly));
		return weekly;
	}

	public List<Weekly> fetchActiveWeeklys() {
		return this.dao.findActiveWeeklys();
	}

	public List<Product> fetchProductsInStockNotInWeekly(Weekly weekly) {
		return this.dao.findProductsInStockNotInWeekly(weekly);
	}


	
}
